<!--提现管理-->
<template>
  <div id="memberUserWithdrawalApplication" class="app-container">
    <!--列表-->
    <div class="table-container flex-main">
      <el-table
        ref="multipleTable"
        :data="list"
        header-cell-class-name="table-header"
        fit
        height="100%"
        highlight-current-row
        @selection-change="handleSelectionChange"
        @row-click="handleRowClick"
        @sort-change="sortChange">
        <el-table-column type="selection" width="60" />
        <el-table-column align="center" prop="id" label="#" width="60">
          <template slot-scope="scope">{{ scope.$index+1 }}</template>
        </el-table-column>
        <el-table-column prop="gmtCreated" sortable label="申请时间" width="160">
          <template slot-scope="scope">{{ scope.row.gmtCreated | formatDate('yyyy-MM-dd hh:mm:ss') }}</template>
        </el-table-column>
        <el-table-column label="提现单号" prop="no" width="180" />
        <el-table-column label="提现金额" prop="money" width="100" sortable show-overflow-tooltip />
        <el-table-column label="提现状态" prop="status" width="100" sortable show-overflow-tooltip>
          <template slot-scope="scope">
            <span v-if="scope.row.status===0" class="color-default">审核中</span>
            <span v-if="scope.row.status===1" class="color-primary">审批通过</span>
            <span v-if="scope.row.status===2" class="color-danger">
              审批拒绝
              <el-tooltip class="item" effect="dark" :content="scope.row.statusDesc" placement="bottom">
                <i v-if="scope.row.statusDesc" class="el-icon-question" />
              </el-tooltip>
            </span>
            <span v-if="scope.row.status===3" class="color-success">打款中</span>
            <span v-if="scope.row.status===4" class="color-primary">转账成功</span>
            <span v-if="scope.row.status===5" class="color-warning">
              转账失败
              <el-tooltip class="item" effect="dark" :content="scope.row.statusDesc" placement="bottom">
                <i v-if="scope.row.statusDesc" class="el-icon-question" />
              </el-tooltip>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="提现原因" prop="reason" min-width="100" sortable show-overflow-tooltip />
        <el-table-column label="通知时间" prop="notifyTime" sortable width="160">
          <template slot-scope="scope">{{ scope.row.notifyTime | formatDate('yyyy-MM-dd hh:mm:ss') }}</template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pagination_handler">
      <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="fetchData" />
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    memberId: {
      type: String,
      default: null
    }

  },
  data() {
    return {
      list: [],
      total: 0,
      listQuery: {
        page: 1,
        limit: this.common.PAGE_LIMIT_DEFAULT,
        keyword: undefined,
        sort: this.common.SORT_DEFAULT
      },

      multipleSelectionRecords: [],
      // 固定写法
      sideBox: {
        recordShow: false,
        title: '',
        status: 'create'
      },
      memberUserWithdrawalApplicationRecord: {},
      memberUserWithdrawalApplicationRules: {
        status: [
          { required: true, message: '请选择审核状态', trigger: 'blur' }
        ]
      }
    }
  },
  watch: {
    memberId: {
      handler(val) {
        if (val) {
          this.listQuery = {
            ...this.listQuery,
            memberId: val
          }
          this.fetchData()
        }
      },
      immediate: true
    }
  },
  created() {
  },
  methods: {
    handleTabClick() {
      this.handleFilter()
    },
    // 表格自带方法开始
    /* 全选/反选*/
    handleSelectionChange(val) {
      this.multipleSelectionRecords = val
    },
    /* 表格行数据单击*/
    handleRowClick(row) {
      this.$refs.multipleTable.toggleRowSelection(row)
    },
    /* 表格列排序*/
    sortChange(data) {
      const { prop, order } = data
      if (prop) {
        if (order === 'ascending') {
          this.listQuery.sort = '+' + prop
        } else {
          this.listQuery.sort = '-' + prop
        }
      } else {
        this.listQuery.sort = this.common.SORT_DEFAULT
      }
      this.handleFilter()
    },
    // 表格自带方法结束

    /* 搜索*/
    handleFilter() {
      this.listQuery = {
        ...this.listQuery,
        page: 1
      }
      this.fetchData()
    },
    /* 重置*/
    handleReset() {
      this.listQuery = {
        ...this.listQuery,
        page: 1,
        limit: this.common.PAGE_LIMIT_DEFAULT,
        keyword: undefined,
        sort: this.common.SORT_DEFAULT
      }
      this.$refs.multipleTable.clearFilter()
      this.$refs.multipleTable.clearSort()
      this.fetchData()
    },
    async fetchData() {
      const response = await this.$store.dispatch('memberUserWithdrawalApplicationPage', this.listQuery)
      this.list = response.records
      this.total = response.total
    }
  }
}
</script>
  <style lang="scss" scoped>
  </style>

